package com.master;

import static com.util.Vessel.*;
import static com.util.Vessel.orderSer;

public class TrolleyCrm {
    //购物车
    public void trolley(int cId,int tId){
        boolean isFlag = true;
        do {
            opMenuSer.vsMealBag(cId,tId);
            System.out.println("1.管理购物车");
            System.out.println("2.继续加购");
            System.out.println("3.菜品的勾选");
            System.out.println("4.下单");
            System.out.println("5.退出");
            int choice = scanner.nextInt();
            switch(choice){
                case 1:
                    manTrolley(cId,tId);
                    break;
                case 2:
                    opMenuSer.orderMeService(cId,tId);
                    break;
                case 3:
                    sMenus(cId,tId);
                    break;
                case 4:
                    boolean isOrder = false;
                    isOrder = opMenu.isNull(cId,tId);
                    if (isOrder){
                        orderSer.OrderMenu(cId,tId);
                    }else {
                        System.out.println("购物车为空，或未勾选菜品,下单失败!");
                    }
                    break;
                case 5:
                    isFlag = false;
                    break;
            }
        }while(isFlag);
    }

    //管理购物车
    public void manTrolley(int cId,int tId){
        System.out.println("1.管理菜品数量");
        System.out.println("2.清空购物车");
        int choice = scanner.nextInt();
        switch (choice){
            case 1:
                opMenuSer.magMealBag(cId,tId);
                break;
            case 2:
                opMenu.cleanAll(cId,tId);
                break;
        }
    }


    //勾选商品
    public void sMenus(int cId,int tId){
        System.out.println("请选择您的操作:");
        System.out.println("1.全勾选");
        System.out.println("2.全取消勾选");
        System.out.println("3.更改菜品勾选状态");
        System.out.println("4.退出");
        int choice = scanner.nextInt();
        switch(choice){
            case 1:
                orderSer.selectAll(cId,tId);
                break;
            case 2:
                orderSer.cancelAll(cId,tId);
                break;
            case 3:
                boolean isNext = false;
                do {
                    opMenuSer.vsMealBag(cId,tId);
                    System.out.println("请输入您想改变选中状态的菜品编号:");
                    int inputmId = scanner.nextInt();
                    orderSer.alter(cId,inputmId,tId);
                    System.out.println("是否继续:1.继续   2.退出操作");
                    int isnext = scanner.nextInt();
                    isNext = (isnext == 1);
                }while (isNext);
                break;
            case 4:
                break;

        }
    }
}
